//
//  GKZYPostBarCommentTableViewCell.m
//  GKZYAid
//
//  Created by lanou3g on 16/3/14.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYPostBarCommentTableViewCell.h"

@implementation GKZYPostBarCommentTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addAllViews];
    }
    return self;
}

- (void)addAllViews
{
    self.backgroundColor = [UIColor whiteColor];
    self.labelUserNameAndComment = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width * 0.05, 0, self.frame.size.width * 0.8, self.frame.size.height)];
    self.labelUserNameAndComment.numberOfLines = 0;
    self.labelUserNameAndComment.userInteractionEnabled = YES;
    [self addSubview:self.labelUserNameAndComment];
    
    self.buttonSkip = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width * 0.5, 40)];
    self.buttonSkip.alpha = 0.5;
    [self.labelUserNameAndComment addSubview:self.buttonSkip];
    self.buttonSkip.userInteractionEnabled = YES;
    
    self.buttonReply = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.labelUserNameAndComment.frame), self.frame.size.width * 0.01, self.frame.size.width * 0.1, self.frame.size.width * 0.1)];
    [self.buttonReply setTitle:@"回复" forState:(UIControlStateNormal)];
    [self.buttonReply setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
    self.buttonReply.font = [UIFont systemFontOfSize:15.0];
    [self addSubview:self.buttonReply];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.labelUserNameAndComment.frame = CGRectMake(self.frame.size.width * 0.05, 0, self.frame.size.width * 0.8, self.frame.size.height);
    
    self.buttonSkip.frame = CGRectMake(0, 0, self.frame.size.width * 0.5, 40);
    
    self.buttonReply.frame = CGRectMake(CGRectGetMaxX(self.labelUserNameAndComment.frame), self.frame.size.width * 0.01, self.frame.size.width * 0.1, self.frame.size.width * 0.1);
}

- (CGFloat)labelHeight:(NSString *)text withFont:(CGFloat)font
{
    CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width * 0.98, 1000);
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:font]};
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height + self.frame.size.width * 0.03;
}

- (void)setStrLabelContent:(NSString *)strLabelContent
{
    NSMutableAttributedString *attributeLabelContent = [[NSMutableAttributedString alloc] initWithString:strLabelContent];
    NSRange range = NSMakeRange(0, [strLabelContent rangeOfString:@":"].location);
    [attributeLabelContent addAttribute:NSForegroundColorAttributeName value:self.color range:range];
    [self.labelUserNameAndComment setAttributedText:attributeLabelContent];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
